package com.cl.ks.flow.util;

import com.cl.ks.entity.ClueAutoResult;
import com.cl.ks.entity.KsFlowNodeResult;
import com.cl.ks.entity.KsFlowResult;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;


public class StaticCollection {
    private static final Map<Integer, CopyOnWriteArrayList<ClueAutoResult>> clueAutoResultListMap = new HashMap<>();
    private static final Map<Integer, CopyOnWriteArrayList<KsFlowNodeResult>> ksFlowNodeResultListMap = new HashMap<>();

    private static final Map<Integer, CopyOnWriteArrayList<KsFlowResult>> ksFlowResultListMap = new HashMap<>();


    private static final Map<Integer, CopyOnWriteArrayList<Integer>> ruleIdListMap = new HashMap<>();

    public static CopyOnWriteArrayList<ClueAutoResult> newClueAutoResultList(Integer key) {
        return clueAutoResultListMap.putIfAbsent(key, new CopyOnWriteArrayList<>());
    }

    public static CopyOnWriteArrayList<ClueAutoResult> getClueAutoResultList(Integer key) {
        return clueAutoResultListMap.get(key);
    }

    public static void removeClueAutoResultList(Integer key) {
        clueAutoResultListMap.remove(key);
    }

    public static CopyOnWriteArrayList<KsFlowNodeResult> newKsFlowNodeResultList(Integer key) {
        return ksFlowNodeResultListMap.putIfAbsent(key, new CopyOnWriteArrayList<>());
    }

    public static CopyOnWriteArrayList<KsFlowResult> newKsFlowResultList(Integer key) {
        return ksFlowResultListMap.putIfAbsent(key, new CopyOnWriteArrayList<>());
    }

    public static CopyOnWriteArrayList<KsFlowNodeResult> getKsFlowNodeResultList(Integer key) {
        return ksFlowNodeResultListMap.get(key);
    }
    public static CopyOnWriteArrayList<KsFlowResult> getKsFlowResultList(Integer key) {
        return ksFlowResultListMap.get(key);
    }

    public static void removeKsFlowNodeResult(Integer key) {
        ksFlowNodeResultListMap.remove(key);
    }

    public static void removeKsFlowResult(Integer key) {
        ksFlowResultListMap.remove(key);
    }

    public static CopyOnWriteArrayList<Integer> newRuleIdListMap(Integer key) {
        return ruleIdListMap.putIfAbsent(key, new CopyOnWriteArrayList<>());
    }

    public static CopyOnWriteArrayList<Integer> getRuleIdListMap(Integer key) {
        return ruleIdListMap.get(key);
    }

    public static void removeRuleIdListMap(Integer key) {
        ruleIdListMap.remove(key);
    }
}
